package Stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/**
 * 随机生成10个10至20之间的随机数(数字允许重复),使用Stream流的技术,找出大于15的元素并打印出来;
 */

public class StreamTest04 {
    public static void main(String[] args) {
        Random random = new Random();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            int num = random.nextInt(11) + 10;
            list.add(num);
        }
        System.out.print("生成的10个随机数是:");
        System.out.println(list);

        List<Integer> collect = list.stream().filter(s -> s > 15).collect(Collectors.toList());
        System.out.print("大于15的元素有:");
        System.out.println(collect);
    }
}
